{% extends "base.html" %}

{% block script %}
<script type="text/javascript" > 

function deletechecked()
{
    var answer = "Realmente deseja remover ?";
    if (confirm(answer)){
    	document.delete_form.submit();
    }
    
    return false;  
}
	 $(function() {
		 $("input[id^='id_data']").datepicker({ dateFormat: 'yy-mm-dd' });
	 });

</script>
{% endblock %}

{% block content %}
<header>
	<h3 class="tabs_involved">{{ title }}</h3>  
</header> 
		<div class="tab_container"> 
			<table class="tablesorter" cellspacing="0">
				<div id="tab1" class="tab_content"> 
					{% if object_list %}
						{% for object in object_list %}
							{% if forloop.first %} 
			    				<thead> 
				                	<tr>
				                    	{% for label, value in object.field_list %}
				                        	<th align="center">{{label}}</th>
				                    	{% endfor %}
				                    	<th align="center" colspan=2> Ações </th>
				            		</tr>
			            		</thead> 
		            		{% endif %}
							<tbody> 
								<tr>
									{% for label, value in object.field_list %}
			                    		<td><a href="/{{link}}/detail/{{object.id}}">{{ value }}</a>
			                		{% endfor %}
			                		<td>
				                		<form action="/{{link}}/update/{{object.id}}"> {% csrf_token %}
			                            	<input type="image" src="/images/template-painel-usuario/icn_edit.png" value="submit" title="Editar" alt="Editar" align="right">  
			                        	</form>
		                        	</td>
		                        	<td>
			                        	<form action="/{{link}}/remove/{{object.id}}" method ="POST" > {% csrf_token %}
			                            	<input type="image" src="/images/template-painel-usuario/icn_trash.png" value="submit" title="Apagar" alt="Apagar" align="left">  
			                        	</form>
		                        	</td>
								</tr>   
							</tbody> 
						{% endfor %}
					{% else %}
						<td align="center">Nada a ser listado</td>
					{% endif %}
					</div>
						<tr>
					    	<td colspan=2>
					    		{% if paginator.num_pages and object_list%}
									Exibindo Página: {{ page_obj.number }} / {{ paginator.num_pages }}<br>
								{% endif%}
								
								{% if page_obj.has_previous %}
									<a href="/{{link}}/page{{ page_obj.previous_page_number }}">Anterior</a>
								{% endif %}
								
								{% if paginator.num_pages and object_list %}
									{% for integer in page_range %}
											<a href="/{{link}}/page{{ integer }}">{{ integer }}</a>
									{% endfor %}
								{% endif%}
								
								{% if page_obj.has_next %}
									<a href="/{{link}}/page{{ page_obj.next_page_number }}">Próxima</a>
								{% endif %}
					    	</td>
					    	<td colspan=2 align="center">
				            	<a href="/{{link}}/create">Adicionar</a>
					    	</td>
					    </tr>
			</table> 
		</div>
	<!-- end of .tab_container --> 
{% endblock %}
